﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;

using log4net;

using CommonLib;
using ConfigUtilLib;

using GmailFetcher.Crawler;
using GmailFetcher.Models;

namespace GmailFetcher
{
    public class GmailCrawlPro : FetcherInterface
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        public FetcherConfigBaseRec getConfiguration(XmlNode fetcherNode)
        {
            EmailAccount gmailConfig = new EmailAccount();
            FetcherConfigBaseRec baseRec = null;


            if( gmailConfig.LoadConfiguration(fetcherNode) )
            {
                baseRec = gmailConfig as FetcherConfigBaseRec;
            }
            
            return baseRec;
        }

        public object crawlForData(FetcherConfigBaseRec configRec)
        {
            EmailAccount gmailAcc = configRec as EmailAccount;

            if (gmailAcc == null)
            {
                return null;
            }

            Object returnObject = EmailCrawler.kickOffCrawling(gmailAcc);
            return returnObject;
        }
    }
}
